<template>
  <div class="audit_article" v-drag>
    <div class="drag">
      <span>{{articleObj.title}}</span>
      <off-btn @off="offAudit"></off-btn>
    </div>
    <div class="article">
      <iframe
      @load="loadArticle"
      :src="articleObj.detail + '?t=' + Math.random()"
      :height="articleHeight" 
      scrolling="no" 
      seamless 
      frameborder="0"></iframe>
    </div>
  </div>
</template>

<script>
import offBtn from "../../../info/offBtn.vue"
export default {
  name: 'Auditarticle',

  data() {
    return {
      articleHeight: 0, // 文章高度
      offIcon: '#icon-guanbi' // 关闭按钮图标
    };
  },

  props: {
    // 当前阅览的文章对象
    articleObj: Object
  },

  methods: {
    // 加载文章内容
    loadArticle(e){
      let article = e.target
      let aHeight = article.contentWindow.document.body.scrollHeight
      let bHeight = article.contentWindow.document.documentElement.scrollHeight
      this.articleHeight = Math.max(aHeight,bHeight)
    },
    // 关闭阅览
    offAudit(){
      this.$emit('offAudit')
    }
  },
  components: {
    offBtn
  }
};
</script>

<style scoped>
.audit_article{
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 50%;
  background-color: white;
  box-shadow: 0 0 5px gray;
}
.audit_article .article{
  height: 400px;
  overflow-y: scroll;
  padding: 30px;
}
.audit_article iframe{
  width: 100%;
}
.audit_article .drag{
  width: 100%;
  height: 30px;
  background-image: linear-gradient(#2eceff,rgb(14, 78, 255));
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
  position: absolute;
  top: 0;
  left: 0;
}
.audit_article .drag .icon{
  font-size: 1.5rem;
  cursor: pointer;
}
</style>